<?php
/*
	PookiWiki - A wiki unlike the rest.
	Copyright (C) 2012 Jordan Craw

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
	
	// Allows me to unlaboriously set properties.
	abstract class PookiAbstractLoader
	{
		protected $class_vars_array = array();
	
		public function __construct()
		{
			$called_class = get_called_class();
			$parent_vars = get_class_vars($called_class);
			
			if(count($parent_vars))
			{
				unset($parent_vars['class_vars_array']);
				$array_contents 	= count(array_keys($parent_vars));
				$arg_nums 			= func_num_args();
				$args				= func_get_args();
				
				if($arg_nums > count($array_contents))
				{
					$args = array_slice($args,0,$arg_nums);
				}
				if($arg_nums == $array_contents)
				{
					$contents = array_keys($parent_vars);
					
					for($i=0; $i <= count($contents)-1;$i++)
					{
						$name = $contents[$i];
						$this->$name = $args[$i];
					}
				}
			}
			
		}
	}
?>